#version 460

#include "project_matrix.glsl"
#include "single_color.glsl"
#include "vertOut.glsl"



layout(location = 0) in vec2 inPos;
layout(location = 1) in vec2 inWeights;



//vec2 pos[4] = {vec2(10.0, 10.0), vec2(100.0, 10.0), vec2(10.0, 100.0), vec2(100.0, 100.0)};
void main(void){
	mat3x2 mat = m_LP_SD[gl_InstanceIndex];

	vec4 v = vec4(0.0, 0.0, 0.0, 1.0);
	//（顶点坐标*比例） + （大小*顶点权重）
	//顶点坐标整体缩放  然后大小变换由输入变换乘顶点权重决定
	//比如圆角矩形 归一化坐标按比例缩放,然后圆角由权重控制,最后加上权重控制的宽高.
	//'(mat[1] - mat[2].x)' 相当于圆角矩形大小减去圆角半径 最终加上 '(inPos.xy * mat[2].x)' 圆角大小
	v.xy = (inPos.xy * mat[2].x) + ((mat[1] - mat[2].x) * inWeights);
	//v.xy = inPos.xy * inWeights * mat[1] * mat[2].x;
	
	v.xy += mat[0];
	v.xy *= m_Scale;
	v.xy += m_Loc;
	
	//v.z = mat[2].y;
	gl_Position = mat_ProjecView * v;
	//gl_Position.xy = roundEven(gl_Position.xy);
	
	vColor = f_buildColor(InstanceColor[gl_InstanceIndex]);
	
	gl_PointSize = 4.0;
}



